package com.luoc.spring.lock;

import java.util.Arrays;

/**
 * @author luoc
 * @version 1.0
 * @date 2021/3/24 20:30
 * @since 1.0
 * 测试synchonized可重入锁，多次执行拿到同一个锁
 */
public class testSynchonized {


    public static void main(String[] args) {
        Son son = new Son();
        son.doSomething();
    }



   static class Son extends Super {
       @Override
       public synchronized void doSomething(){
           super.doSomething();
           System.out.println("son.doSomething------" + Thread.currentThread().getName());
           doAnotherthing();
       }

       public synchronized void doAnotherthing(){
           System.out.println("super.doAnotherthing------" + Thread.currentThread().getName());
       }

   }


    static  class Super {
        public synchronized void doSomething(){
            System.out.println("super.doSomething------" + Thread.currentThread().getName());
        }
    }
}
